home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / c_math.zip / TANH.C < prev   
Text File  |  1983-07-02  |  404b  |  28 lines

  1. /*
  2.     tanh(arg) computes the hyperbolic tangent of its floating
  3.     point argument.
  4.  
  5.     sinh and cosh are called except for large arguments, which
  6.     would cause overflow improperly.
  7. */
  8.  
  9. double sinh(), cosh();
  10.  
  11. double
  12. tanh(arg)
  13. double arg;
  14. {
  15.     double sign;
  16.  
  17.     sign = 1.;
  18.     if(arg < 0.){
  19.         arg = -arg;
  20.         sign = -1.;
  21.     }
  22.  
  23.     if(arg > 21.)
  24.         return(sign);
  25.  
  26.     return(sign*sinh(arg)/cosh(arg));
  27. }
  28.